Contents | < Browse | Browse >
IF [NOT][WARN][ERROR][FAIL][EXISTS file]
* The IF command allows conditional execution of statements
following it.
* If the condition specified is true, then execution continues
after the IF statement until either an ENDIF or ELSE statement
is encountered. If it is an ELSE statement, then all statements
between the ELSE and the closing ENDIF are skipped.
* If the condition is false, then all statements after the IF and
before either an ENDIF or ELSE statement are skipped. If an ELSE
is encountered, then execution continues for all statements after
the ELSE and before the closing ENDIF.
* IF can examine the state of the return code from the last command
execute with WARN, ERROR, and FAIL tests. You can test for the
non existence of such a state by including the optional NOT
parameter.
eg. IF WARN
echo "last command returned warnings"
ELSE
echo "last command did not return warnings"
ENDIF
IF NOT FAIL
echo "last command did not fail"
ENDIF
* IF can also test for the existence of a file or directory.
eg. IF EXISTS :system/format
echo "this disk has a format command"
echo "you can look yourself. I'm not joking"
ENDIF
IF NOT EXISTS ram:ed
copy c:ed ram:
ENDIF